

<!DOCTYPE html>
<html lang="en" data-default-color-scheme=dark>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/head.png">
  <link rel="icon" href="/img/head.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Wei Ruitong">
  <meta name="keywords" content="">
  
    <meta name="description" content="LuckFox pico Pro&#x2F;Max一、命令1.1、修改系统时间12345678910111213141516171819202122232425&#x2F;&#x2F; 查看系统时间# dateFri Jan  1 12:24:06 UTC 2021&#x2F;&#x2F; 查看硬件时间# hwclockFri Jan  1 12:24:19 2021  0.000000 seconds&#x2F;&#x2F; 修改系统时间# date -">
<meta property="og:type" content="article">
<meta property="og:title" content="Luckfox Pico Pro Max笔记">
<meta property="og:url" content="http://example.com/2024/04/11/Luckfox-Pico-Pro-Max%E7%AC%94%E8%AE%B0/index.html">
<meta property="og:site_name" content="WRT">
<meta property="og:description" content="LuckFox pico Pro&#x2F;Max一、命令1.1、修改系统时间12345678910111213141516171819202122232425&#x2F;&#x2F; 查看系统时间# dateFri Jan  1 12:24:06 UTC 2021&#x2F;&#x2F; 查看硬件时间# hwclockFri Jan  1 12:24:19 2021  0.000000 seconds&#x2F;&#x2F; 修改系统时间# date -">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="http://example.com/img/Luckfox.png">
<meta property="article:published_time" content="2024-04-11T06:25:08.000Z">
<meta property="article:modified_time" content="2024-04-11T08:06:54.935Z">
<meta property="article:author" content="Wei Ruitong">
<meta property="article:tag" content="LVGL">
<meta property="article:tag" content="Luckfox Pico">
<meta property="article:tag" content="RV1106">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="http://example.com/img/Luckfox.png">
  
  
  
  <title>Luckfox Pico Pro Max笔记 - WRT</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.9.7","typing":{"enable":false,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"left","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":{"measurement_id":null},"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml","include_content_in_search":true};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 60vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>Ruitong&#39;s blog</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/" target="_self">
                <i class="iconfont icon-home-fill"></i>
                <span>主页</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/" target="_self">
                <i class="iconfont icon-category-fill"></i>
                <span>分类</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/" target="_self">
                <i class="iconfont icon-user-fill"></i>
                <span>关于</span>
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/default.jpg') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle">Luckfox Pico Pro Max笔记</span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2024-04-11 14:25" pubdate>
          April 11, 2024 pm
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          4.4k words
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          37 mins
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="padding-left: 2rem; margin-right: -1rem">
    <div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>Table of Contents</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <h1 id="seo-header">Luckfox Pico Pro Max笔记</h1>
            
            
              <div class="markdown-body">
                
                <h1 id="LuckFox-pico-Pro-Max"><a href="#LuckFox-pico-Pro-Max" class="headerlink" title="LuckFox pico Pro&#x2F;Max"></a>LuckFox pico Pro&#x2F;Max</h1><h2 id="一、命令"><a href="#一、命令" class="headerlink" title="一、命令"></a>一、命令</h2><h3 id="1-1、修改系统时间"><a href="#1-1、修改系统时间" class="headerlink" title="1.1、修改系统时间"></a>1.1、修改系统时间</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><code class="hljs shell">// 查看系统时间<br><span class="hljs-meta prompt_"># </span><span class="language-bash"><span class="hljs-built_in">date</span></span><br>Fri Jan  1 12:24:06 UTC 2021<br><br>// 查看硬件时间<br><span class="hljs-meta prompt_"># </span><span class="language-bash">hwclock</span><br>Fri Jan  1 12:24:19 2021  0.000000 seconds<br><br>// 修改系统时间<br><span class="hljs-meta prompt_"># </span><span class="language-bash"><span class="hljs-built_in">date</span> -s <span class="hljs-string">&quot;2023-12-07 11:41:00&quot;</span></span><br>Thu Dec  7 11:41:00 UTC 2023<br><br>// 根据系统时间更改硬件RTC时间,接电池，断电时间不丢失<br><span class="hljs-meta prompt_"># </span><span class="language-bash">hwclock -w</span><br><br>// 结果<br><span class="hljs-meta prompt_"># </span><span class="language-bash"><span class="hljs-built_in">date</span></span><br>Thu Dec  7 11:46:30 UTC 2023<br><span class="hljs-meta prompt_"># </span><span class="language-bash">hwclock</span><br>Thu Dec  7 11:46:39 2023  0.000000 seconds<br><br>// 可以使用python输出系统时间<br>from datetime import datetime<br>current_time = datetime.now()<br>print(cuttent_time)<br></code></pre></td></tr></table></figure>

<h3 id="1-2、后台执行任务"><a href="#1-2、后台执行任务" class="headerlink" title="1.2、后台执行任务"></a>1.2、后台执行任务</h3><blockquote>
<p>当在窗口运行一个死循环程序时，终端会一直等待进程完成，无法输入其他命令。如果你想在后台运行任务而不锁定终端，可以在命令末尾添加 <code>&amp;</code> 符号。如： python main.py&amp;。</p>
</blockquote>
<h2 id="二、添加库"><a href="#二、添加库" class="headerlink" title="二、添加库"></a>二、添加库</h2><h3 id="2-1、python添加MQTT库"><a href="#2-1、python添加MQTT库" class="headerlink" title="2.1、python添加MQTT库"></a>2.1、python添加MQTT库</h3><h4 id="2-1-1-添加步骤"><a href="#2-1-1-添加步骤" class="headerlink" title="2.1.1 添加步骤"></a>2.1.1 添加步骤</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><code class="hljs shell">// 以下指令均在docker环境下运行<br><br>// 进入docker环境（第二次）<br>sudo docker start -ai luckfox<br><br>// 设置交叉编译工具链（可在docker环境下）<br>cd &lt;SDK目录&gt;/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/<br>source env_install_toolchain.sh<br><br>// 进入home目录，设置开发板<br>./build.sh lunch<br><br>// 进入buildroot目录，开启python-paho-mqtt库<br>cd /home/sysdrv/source/buildroot/buildroot-2023.02.6<br>make menuconfig<br>Target packages &gt; Interpreter languages and scripting &gt; python3<br><span class="hljs-meta prompt_">&gt; </span><span class="language-bash">External python modules &gt; python-paho-mqtt</span><br><br>// save保存，多次双击ESC，退出菜单界面<br><br>// 指令再次保存,编译<br>make savedefconfig<br>make <br><br>// 退回到home文件夹，重新编译，时间比较短(没clean的话)<br>./build.sh <br></code></pre></td></tr></table></figure>

<h4 id="2-1-2测试"><a href="#2-1-2测试" class="headerlink" title="2.1.2测试"></a>2.1.2测试</h4><blockquote>
<p>测试使用OneNet的MQTT服务器，需要从平台上获取到：设备ID、产品ID、鉴权信息。将下面的程序，修改星号处信息，直接复制到开发板上运行即可。</p>
</blockquote>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-keyword">import</span> paho.mqtt.client <span class="hljs-keyword">as</span> mqtt<br><span class="hljs-keyword">import</span> time<br>// 需要修改的信息<br>client_id = <span class="hljs-string">&#x27;****************&#x27;</span><br>product_id = <span class="hljs-string">&#x27;***************&#x27;</span><br>master_apikey = <span class="hljs-string">&#x27;************&#x27;</span><br>// OneNet 服务器ip地址与端口号<br>serverip = <span class="hljs-string">&#x27;183.230.40.39&#x27;</span><br>port = <span class="hljs-number">6002</span><br>// 订阅的主题名字<br>topic = <span class="hljs-string">&#x27;TEST_RECEIVE&#x27;</span><br><span class="hljs-keyword">def</span> <span class="hljs-title function_">Message</span>(<span class="hljs-params">client, userdata, message</span>):<br>    <span class="hljs-comment"># print(message.topic)</span><br>    <span class="hljs-built_in">print</span>(message.payload.decode(<span class="hljs-string">&#x27;utf-8&#x27;</span>))<br><br>client = mqtt.Client(client_id=client_id, clean_session=<span class="hljs-literal">True</span>, userdata=<span class="hljs-literal">None</span>, protocol=mqtt.MQTTv311, transport=<span class="hljs-string">&quot;tcp&quot;</span>)<br>client.username_pw_set(product_id, master_apikey)<br>client.on_message = Message<br>client.connect(serverip, port, <span class="hljs-number">60</span>)<br>client.subscribe(topic)<br>client.loop_start()<br><span class="hljs-keyword">while</span> <span class="hljs-literal">True</span>:<br>    time.sleep(<span class="hljs-number">5</span>)<br>    // 发布Qos0，Topic:TEST_SEND<br>    client.publish(<span class="hljs-string">&quot;TEST_SEND&quot;</span>, <span class="hljs-string">&quot;helloworld!&quot;</span>, <span class="hljs-number">0</span>)<br></code></pre></td></tr></table></figure>

<h3 id="2-2、添加ffmpeg支持"><a href="#2-2、添加ffmpeg支持" class="headerlink" title="2.2、添加ffmpeg支持"></a>2.2、添加ffmpeg支持</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs shell">cd /home/sysdrv/source/buildroot/buildroot-2023.02.6<br>make menuconfig<br>Target packages &gt; Audio and video applications &gt; ffmpeg<br><br><br>make savedefconfig<br>make <br><br>// 退回到home文件夹，重新编译，时间比较短(没clean的话)<br>./build.sh <br><br></code></pre></td></tr></table></figure>



<h2 id="三、添加设备"><a href="#三、添加设备" class="headerlink" title="三、添加设备"></a>三、添加设备</h2><h3 id="3-1-添加屏幕（2-8-inch-st7789v-320-240）"><a href="#3-1-添加屏幕（2-8-inch-st7789v-320-240）" class="headerlink" title="3.1 添加屏幕（2.8 inch  st7789v 320*240）"></a>3.1 添加屏幕（2.8 inch  st7789v 320*240）</h3><blockquote>
<p><a target="_blank" rel="noopener" href="https://github.com/notro/fbtft/wiki/Device-Tree">fbtft仓库连接，设备树可参考</a></p>
</blockquote>
<h4 id="3-1-1-修改设备树"><a href="#3-1-1-修改设备树" class="headerlink" title="3.1.1 修改设备树"></a>3.1.1 修改设备树</h4><blockquote>
<ol>
<li><p>在设备树文件的根下,添加引脚</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-comment">// add by Wei Ruitong ,23/12/17</span><br>	<span class="hljs-comment">/*LCD_CS -- USE MISO*/</span><br>    gpio1pc3:gpio1pc3 &#123;<br>        compatible = <span class="hljs-string">&quot;regulator-fixed&quot;</span>;<br>        pinctrl-names = <span class="hljs-string">&quot;default&quot;</span>;<br>        pinctrl<span class="hljs-number">-0</span> = &lt;&amp;gpio1_pc3&gt;;<br>        regulator-name = <span class="hljs-string">&quot;gpio1_pc3&quot;</span>;<br>        regulator-always-on;<br>    &#125;;<br>	<span class="hljs-comment">/*LCD_DC*/</span><br>    gpio1pd0:gpio1pd0 &#123;<br>        compatible = <span class="hljs-string">&quot;regulator-fixed&quot;</span>;<br>        pinctrl-names = <span class="hljs-string">&quot;default&quot;</span>;<br>        pinctrl<span class="hljs-number">-0</span> = &lt;&amp;gpio1_pd0&gt;;<br>        regulator-name = <span class="hljs-string">&quot;gpio1_pd0&quot;</span>;<br>        regulator-always-on;<br>    &#125;;<br>	<span class="hljs-comment">/*LCD_RES*/</span><br>    gpio1pd1:gpio1pd1 &#123;<br>        compatible = <span class="hljs-string">&quot;regulator-fixed&quot;</span>;<br>        pinctrl-names = <span class="hljs-string">&quot;default&quot;</span>;<br>        pinctrl<span class="hljs-number">-0</span> = &lt;&amp;gpio1_pd1&gt;;<br>        regulator-name = <span class="hljs-string">&quot;gpio1_pd1&quot;</span>;<br>        regulator-always-on;<br>    &#125;;<br></code></pre></td></tr></table></figure>
</li>
<li><p>pinctrl 配置引脚的电气属性</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><code class="hljs c">&amp;pinctrl &#123;<br>	<span class="hljs-comment">/*LCD_CS -- USE MISO*/</span><br>    gpio1-pc3 &#123;<br>        gpio1_pc3:gpio1-pc3 &#123;<br>            rockchip,pins = &lt;<span class="hljs-number">1</span> RK_PC3 RK_FUNC_GPIO &amp;pcfg_pull_none&gt;;<br>        &#125;;<br>    &#125;;<br>	<span class="hljs-comment">/*LCD_DC*/</span><br>    gpio1-pd0 &#123;<br>        gpio1_pd0:gpio1-pd0 &#123;<br>            rockchip,pins = &lt;<span class="hljs-number">1</span> RK_PD0 RK_FUNC_GPIO &amp;pcfg_pull_none&gt;;<br>        &#125;;<br>    &#125;;<br>	<span class="hljs-comment">/*LCD_RES*/</span><br>    gpio1-pd1 &#123;<br>        gpio1_pd1:gpio1-pd1 &#123;<br>            rockchip,pins = &lt;<span class="hljs-number">1</span> RK_PD1 RK_FUNC_GPIO &amp;pcfg_pull_none&gt;;<br>        &#125;;<br>    &#125;;<br>    spi0 &#123;<br>        /omit-<span class="hljs-keyword">if</span>-no-ref/<br>        spi0m0_pins: spi0m0-pins &#123;<br>            rockchip,pins =<br>                <span class="hljs-comment">/* spi0_clk_m0 */</span><br>                &lt;<span class="hljs-number">1</span> RK_PC1 <span class="hljs-number">4</span> &amp;pcfg_pull_none&gt;,<br>                <span class="hljs-comment">/* spie_miso_m0 */</span><br>                <span class="hljs-comment">/* &lt;1 RK_PC3 6 &amp;pcfg_pull_none&gt;, */</span>	<br>                <span class="hljs-comment">/* spi_mosi_m0 */</span><br>                &lt;<span class="hljs-number">1</span> RK_PC2 <span class="hljs-number">6</span> &amp;pcfg_pull_none&gt;;<br>        &#125;;<br>    &#125;;<br>&#125;;<br></code></pre></td></tr></table></figure>
</li>
<li><p>在spi节点下添加st7789设备</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><code class="hljs c">&amp;spi0 &#123;<br>	status = <span class="hljs-string">&quot;okay&quot;</span>;<br>	pinctrl-names = <span class="hljs-string">&quot;default&quot;</span>;<br>	pinctrl<span class="hljs-number">-0</span> = &lt;&amp;spi0m0_pins&gt;;<br>	<span class="hljs-comment">// cs-gpios = &lt;&amp;gpio1 RK_PC0 1&gt;;</span><br>	<span class="hljs-comment">// cs-gpios = &lt;&amp;gpio1 26 1&gt;;</span><br>	<span class="hljs-meta">#address-cells = <span class="hljs-string">&lt;1&gt;</span>;</span><br>	<span class="hljs-meta">#size-cells = <span class="hljs-string">&lt;0&gt;</span>;</span><br>	<span class="hljs-comment">/*</span><br><span class="hljs-comment">	spidev@0 &#123;</span><br><span class="hljs-comment">		compatible = &quot;rockchip,spidev&quot;;</span><br><span class="hljs-comment">		spi-max-frequency = &lt;1000000000&gt;;</span><br><span class="hljs-comment">		reg = &lt;0&gt;;</span><br><span class="hljs-comment">	&#125;;</span><br><span class="hljs-comment">	*/</span><br>	st7789v: st7789v@<span class="hljs-number">0</span>&#123;<br>         status = <span class="hljs-string">&quot;okay&quot;</span>;<br>         compatible = <span class="hljs-string">&quot;sitronix,st7789v&quot;</span>;<br>         spi-max-frequency = &lt;<span class="hljs-number">48000000</span>&gt;;<br>		reg = &lt;<span class="hljs-number">0</span>&gt;;  <br>         rotate = &lt;<span class="hljs-number">90</span>&gt;; <br>         fps = &lt;<span class="hljs-number">60</span>&gt;;<br>         rgb;<br>         buswidth = &lt;<span class="hljs-number">8</span>&gt;;<br>         dc-gpios = &lt;&amp;gpio1 RK_PD0 GPIO_ACTIVE_HIGH&gt;;<br>         reset-gpios = &lt;&amp;gpio1 RK_PD1 GPIO_ACTIVE_LOW&gt;;<br>		cs-gpios = &lt;&amp;gpio1 RK_PC3 GPIO_ACTIVE_LOW&gt;; <br>    &#125;;<br>	<br>&#125;;<br></code></pre></td></tr></table></figure>
</li>
<li><p>背光调节，在根路径下添加如下代码,使用的是pwm5_m1,即引脚GPIO2_B0_d</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs c">lcd_backlight:backlight &#123;<br>		compatible = <span class="hljs-string">&quot;pwm-backlight&quot;</span>;<br>		pinctrl-names = <span class="hljs-string">&quot;default&quot;</span>;<br>		pinctrl<span class="hljs-number">-0</span> = &lt;&amp;pwm5m1_pins&gt;;<br>		status = <span class="hljs-string">&quot;okay&quot;</span>;<br>		pwms = &lt;&amp;pwm5 <span class="hljs-number">0</span> <span class="hljs-number">500000</span> <span class="hljs-number">0</span>&gt;;<br>		pwm-names = <span class="hljs-string">&quot;backlight&quot;</span>;<br>		brightness-levels = &lt;<span class="hljs-number">0</span> <span class="hljs-number">4</span> <span class="hljs-number">8</span> <span class="hljs-number">16</span> <span class="hljs-number">32</span> <span class="hljs-number">64</span> <span class="hljs-number">128</span> <span class="hljs-number">255</span>&gt;;<br>		<span class="hljs-keyword">default</span>-brightness-level = &lt;<span class="hljs-number">7</span>&gt;; <br>&#125;;<br></code></pre></td></tr></table></figure></li>
</ol>
</blockquote>
<h4 id="3-1-2-内核添加设备"><a href="#3-1-2-内核添加设备" class="headerlink" title="3.1.2 内核添加设备"></a>3.1.2 内核添加设备</h4><blockquote>
<ol>
<li><p>在kernal目录下</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs shell">cp ./arch/arm/configs/luckfox_rv1106_linux_defconfig .config<br>make ARCH=arm menuconfig<br></code></pre></td></tr></table></figure>
</li>
<li><p>、执行<code>make menuconfig</code> 命令</p>
<p>使能 <code>Device Drivers &gt; Staging Drivers &gt; Support for small TFT LCD display modules &gt; FB Driver for the ST7789V LCD Controller</code></p>
</li>
<li><p>使能SPI中的选项</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs c">CONFIG_SPI_MASTER=y<br><br>CONFIG_SPI_DESIGNWARE=y<br><br>CONFIG_SPI_DW_MMIO=y<br></code></pre></td></tr></table></figure>
</li>
<li><p>使能FB中的其他选项</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs c">CONFIG_FB=y <br><br>CONFIG_FB_TFT=y<br></code></pre></td></tr></table></figure>
</li>
<li><p>保存</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs shell">make ARCH=arm savedefconfig<br>cp defconfig ./arch/arm/configs/luckfox_rv1106_linux_defconfig<br></code></pre></td></tr></table></figure>
</li>
<li><p>回到&#x2F;home路径下，不要clean项目，否侧配置会丢失，直接编译</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs shell">// 选择开发板MAX，4<br>./build.sh lunch <br>                                          <br>// 编译项目<br>./build.sh <br></code></pre></td></tr></table></figure></li>
</ol>
</blockquote>
<h4 id="3-1-3-测试"><a href="#3-1-3-测试" class="headerlink" title="3.1.3 测试"></a>3.1.3 测试</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><code class="hljs shell"><span class="hljs-meta prompt_"># </span><span class="language-bash">运行命令,屏幕出现花屏</span><br>cat /dev/urandom &gt; /dev/fb0<br><span class="hljs-meta prompt_"></span><br><span class="hljs-meta prompt_"># </span><span class="language-bash">运行命令，屏幕变为全黑</span><br>cat /dev/zero &gt; /dev/fb0<br><span class="hljs-meta prompt_"></span><br><span class="hljs-meta prompt_"># </span><span class="language-bash">调节屏幕背光等级</span><br>cd /sys/class/backlight/backlight<br><span class="hljs-meta prompt_"># </span><span class="language-bash">将背光亮度调节为0级，最暗</span><br>echo 1 &gt; brightness<br><span class="hljs-meta prompt_"># </span><span class="language-bash">将背光亮度调节为7级，最亮</span><br>echo 7 &gt; brightness<br><span class="hljs-meta prompt_"></span><br><span class="hljs-meta prompt_"># </span><span class="language-bash">c语言修改屏幕亮度</span><br><span class="hljs-meta prompt_">	#</span><span class="language-bash">include &lt;stdio.h&gt;</span><br><span class="hljs-meta prompt_">	#</span><span class="language-bash">include &lt;stdlib.h&gt;</span><br>	<br>	FILE *brightnessFile;<br>    char path[45];<br>    // 指定brightness文件的路径<br>    sprintf(path, &quot;%s&quot;, &quot;/sys/class/backlight/backlight/brightness&quot;);<br>    // 以写入方式打开文件<br>    brightnessFile = fopen(path, &quot;w&quot;);<br><br>    if (brightnessFile == NULL) &#123;<br>        perror(&quot;Error opening brightness file&quot;);<br>        exit(EXIT_FAILURE);<br>    &#125;<br>    // 将亮度值写入文件，这里直接读取lvgl中的值<br>    lv_obj_t * slider = lv_event_get_target(e);<br>    fprintf(brightnessFile, &quot;%d&quot;, (int)lv_slider_get_value(slider));<br><br>    // 关闭文件<br>    fclose(brightnessFile);<br></code></pre></td></tr></table></figure>

<p><img src="/img/st7789.png" srcset="/img/loading.gif" lazyload alt="image-20231218110416478"></p>
<h3 id="3-2-添加触摸屏（GT911）"><a href="#3-2-添加触摸屏（GT911）" class="headerlink" title="3.2 添加触摸屏（GT911）"></a>3.2 添加触摸屏（GT911）</h3><h4 id="3-2-1-修改设备树"><a href="#3-2-1-修改设备树" class="headerlink" title="3.2.1 修改设备树"></a>3.2.1 修改设备树</h4><blockquote>
<ol>
<li><p>在根节点中定义中断和复位GPIO</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-comment">/*TOUCH_RST*/</span><br>gpio1pc0:gpio1pc0 &#123;<br>       compatible = <span class="hljs-string">&quot;regulator-fixed&quot;</span>;<br>       pinctrl-names = <span class="hljs-string">&quot;default&quot;</span>;<br>       pinctrl<span class="hljs-number">-0</span> = &lt;&amp;gpio1_pc0&gt;;<br>       regulator-name = <span class="hljs-string">&quot;gpio1_pc0&quot;</span>;<br>       regulator-always-on;<br>   &#125;;<br>   <br><span class="hljs-comment">/*TOUCH_INT*/</span><br>   gpio2pb1:gpio2pb1 &#123;<br>       compatible = <span class="hljs-string">&quot;regulator-fixed&quot;</span>;<br>       pinctrl-names = <span class="hljs-string">&quot;default&quot;</span>;<br>       pinctrl<span class="hljs-number">-0</span> = &lt;&amp;gpio2_pb1&gt;;<br>       regulator-name = <span class="hljs-string">&quot;gpio2_pb1&quot;</span>;<br>       regulator-always-on;<br>   &#125;;<br></code></pre></td></tr></table></figure>
</li>
<li><p>在pinctrl中配置GPIO属性</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-comment">/* TOUCH_INT */</span><br>gpio1-pc0 &#123;<br>       gpio1_pc0:gpio1-pc0 &#123;<br>           rockchip,pins = &lt;<span class="hljs-number">1</span> RK_PC0 RK_FUNC_GPIO &amp;pcfg_pull_none&gt;;<br>       &#125;;<br>   &#125;;<br><span class="hljs-comment">/* TOUCH_RST */</span><br>gpio2-pb1 &#123;<br>       gpio2_pb1:gpio2-pb1 &#123;<br>           rockchip,pins = &lt;<span class="hljs-number">2</span> RK_PB1 RK_FUNC_GPIO &amp;pcfg_pull_none&gt;;<br>       &#125;;<br>   &#125;;<br></code></pre></td></tr></table></figure>
</li>
<li><p>在pinctrl中配置I2C3引脚</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs c">i2c3 &#123;<br>        /omit-<span class="hljs-keyword">if</span>-no-ref/<br>        i2c3m1_xfer: i2c3m1-xfer &#123;<br>            rockchip,pins =<br>                <span class="hljs-comment">/* i2c3_scl_m1 */</span><br>                &lt;<span class="hljs-number">1</span> RK_PD3 <span class="hljs-number">3</span> &amp;pcfg_pull_up&gt;,<br>                <span class="hljs-comment">/* i2c3_sda_m1 */</span><br>                &lt;<span class="hljs-number">1</span> RK_PD2 <span class="hljs-number">3</span> &amp;pcfg_pull_up&gt;;<br>        &#125;;  <br>    &#125;;<br></code></pre></td></tr></table></figure>
</li>
<li><p>在I2C3中添加gt911设备，注意设备地址0x14 或 0x5d中的一个</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><code class="hljs c">&amp;i2c3 &#123;<br>	status = <span class="hljs-string">&quot;okay&quot;</span>;<br>	pinctrl-names = <span class="hljs-string">&quot;default&quot;</span>;<br>	pinctrl<span class="hljs-number">-0</span> = &lt;&amp;i2c3m1_xfer&gt;;<br>	clock-frequency = &lt;<span class="hljs-number">400000</span>&gt;;<br>                                          <br>	gt911: gt911@<span class="hljs-number">14</span> &#123;<br>		compatible = <span class="hljs-string">&quot;goodix,gt911&quot;</span>;<br>		reg = &lt;<span class="hljs-number">0x14</span>&gt;;<br>		interrupt-parent = &lt;&amp;gpio1&gt;;<br>		interrupts = &lt;RK_PC0 IRQ_TYPE_EDGE_FALLING&gt;;<br>		pinctrl-names = <span class="hljs-string">&quot;default&quot;</span>;<br>		<span class="hljs-comment">//pinctrl-0 = &lt;&amp;gpio2_pb1 &amp;gpio1_pc0&gt;;</span><br>		reset-gpios = &lt;&amp;gpio2 RK_PB1 GPIO_ACTIVE_LOW&gt;;<br>		irq-gpios = &lt;&amp;gpio1 RK_PC0 GPIO_ACTIVE_LOW&gt;;<br>		touchscreen-size-y = &lt;<span class="hljs-number">240</span>&gt;;<br>		touchscreen-size-x = &lt;<span class="hljs-number">320</span>&gt;;<br>		<span class="hljs-comment">/* touchscreen-inverted-x; */</span><br>		<span class="hljs-comment">/* touchscreen-inverted-y; */</span><br>		<span class="hljs-comment">/* touchscreen-swapped-x-y;*/</span><br>&#125;;<br></code></pre></td></tr></table></figure></li>
</ol>
</blockquote>
<h4 id="3-2-2-内核添加触摸设备"><a href="#3-2-2-内核添加触摸设备" class="headerlink" title="3.2.2 内核添加触摸设备"></a>3.2.2 内核添加触摸设备</h4><blockquote>
<ol>
<li>make menuconfig</li>
<li>使能 Device Drivers &gt; Input device support &gt;Touchreens &gt; Goodix I2C touchscreen</li>
</ol>
</blockquote>
<h4 id="3-2-3-测试"><a href="#3-2-3-测试" class="headerlink" title="3.2.3 测试"></a>3.2.3 测试</h4><blockquote>
<ol>
<li><p>系统信息</p>
<p><img src="/img/input.png" srcset="/img/loading.gif" lazyload alt="image-20231218111437805"></p>
</li>
<li><p>进入<code>/dev/input</code>目录能够看到比原来多了一个<code>event</code>，使用hexdump命令查看，触摸屏幕，会打印如下信息</p>
<p><img src="/img/event.png" srcset="/img/loading.gif" lazyload alt="image-20231218111746545"></p>
</li>
</ol>
</blockquote>
<h4 id="3-2-4-问题"><a href="#3-2-4-问题" class="headerlink" title="3.2.4 问题"></a>3.2.4 问题</h4><blockquote>
<ol>
<li><p>玩lvgl时发现触摸点和响应点不是一个点。</p>
<p>答：屏幕驱动方向的问题，两种方法更改</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-comment">// 在设备树gt911节点下进行更改</span><br><span class="hljs-comment">/* touchscreen-inverted-x; */</span><br><span class="hljs-comment">/* touchscreen-inverted-y; */</span><br><span class="hljs-comment">/* touchscreen-swapped-x-y;*/</span><br><br><span class="hljs-comment">// 在lv_drivers的配置文件lv_drv_config.h中更改</span><br><span class="hljs-meta">#  <span class="hljs-keyword">define</span> EVDEV_SWAP_AXES         1               <span class="hljs-comment">/*Swap the x and y axes of the touchscreen*/</span></span><br><br><span class="hljs-comment">//可结合两种方式自行调整</span><br></code></pre></td></tr></table></figure>
</li>
<li><p>如果上述各种组合都无法解决问题（比如上下滑动正常，单左右滑动反了，可参考如下解决办法），又不想修改linux自带的goodix驱动，可以修改<code>lv_drivers/indev/evdev.c</code>文件，注意这里已经使能EVDEV_SWAP_AXES宏了，如果未使能，修改else中的内容即可。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-comment">// 比如我的上下滑动正常，但是左右滑动刚好相反</span><br><span class="hljs-comment">// 找到文件中的evdev_read()函数，局部代码如下</span><br><span class="hljs-comment">// 可以使用printf（）函数，输出当前坐标，比如左上角就应该是（0,0）坐标，右下角应该是（320,240）</span><br><span class="hljs-comment">// 如果和你预想的不一样，需要根据情况进行调整</span><br><span class="hljs-keyword">if</span>(in.code == ABS_X)<br>				<span class="hljs-meta">#<span class="hljs-keyword">if</span> EVDEV_SWAP_AXES</span><br>					evdev_root_y = in.value;<br>				<span class="hljs-meta">#<span class="hljs-keyword">else</span></span><br>					evdev_root_x = in.value;<br>				<span class="hljs-meta">#<span class="hljs-keyword">endif</span></span><br>            <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(in.code == ABS_Y)<br>				<span class="hljs-meta">#<span class="hljs-keyword">if</span> EVDEV_SWAP_AXES</span><br>					evdev_root_x = <span class="hljs-number">320</span> - in.value;  		<span class="hljs-comment">// 左右刚好相反，用横最大像素减去当前像素，才是真实的触点</span><br>				<span class="hljs-meta">#<span class="hljs-keyword">else</span></span><br>					evdev_root_y = in.value;<br>				<span class="hljs-meta">#<span class="hljs-keyword">endif</span></span><br>            <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(in.code == ABS_MT_POSITION_X)<br>                                <span class="hljs-meta">#<span class="hljs-keyword">if</span> EVDEV_SWAP_AXES</span><br>                                        evdev_root_y = in.value;<br>                                <span class="hljs-meta">#<span class="hljs-keyword">else</span></span><br>                                        evdev_root_x =in.value;<br>                                <span class="hljs-meta">#<span class="hljs-keyword">endif</span></span><br>            <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(in.code == ABS_MT_POSITION_Y)<br>                                <span class="hljs-meta">#<span class="hljs-keyword">if</span> EVDEV_SWAP_AXES</span><br>                                        evdev_root_x = <span class="hljs-number">320</span> - in.value;  <span class="hljs-comment">// 同理</span><br>                                <span class="hljs-meta">#<span class="hljs-keyword">else</span></span><br>                                        evdev_root_y = in.value;<br>                                <span class="hljs-meta">#<span class="hljs-keyword">endif</span></span><br></code></pre></td></tr></table></figure>

<p><img src="/img/yunxing.PNG" srcset="/img/loading.gif" lazyload alt="yunxing"></p>
</li>
</ol>
</blockquote>
<h3 id="3-3-温湿度DHT11"><a href="#3-3-温湿度DHT11" class="headerlink" title="3.3 温湿度DHT11"></a>3.3 温湿度DHT11</h3><ol>
<li><p>修改设备树,并注释掉UART4，应为公用了同一个引脚，具体使用方法可看kernel目录下的dht11.txt文档<code>kernel/Documentation/devicetree/bindings/iio/humidity/dht11.txt</code></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><code class="hljs shell">/&#123;<br>    humidity_sensor &#123;<br>        compatible = &quot;dht11&quot;;<br>        pinctrl-names = &quot;default&quot;;<br>        status = &quot;okay&quot;;<br>        pinctrl-0 = &lt;&amp;gpio1_pc4&gt;;<br>        gpios = &lt;&amp;gpio1 RK_PC4 GPIO_ACTIVE_HIGH&gt;; <br>    &#125;;<br>&#125;;<br><br>&amp;pinctrl &#123;<br>    gpio1-pc4 &#123;<br>        gpio1_pc4:gpio1-pc4 &#123;<br>                rockchip,pins = &lt;1 RK_PC4 RK_FUNC_GPIO &amp;pcfg_pull_none&gt;;<br>        &#125;;<br>    &#125;;<br>&#125;;<br></code></pre></td></tr></table></figure>
</li>
<li><p>kernel中打开dht11驱动</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs shell">make menuconfig<br><span class="hljs-meta prompt_"># </span><span class="language-bash">使能</span><br>Device Drivers &gt; Industrial I/O support &gt; Humidity sensors<br></code></pre></td></tr></table></figure>
</li>
<li><p>驱动报错<code>[   24.069548] dht11 humidity_sensor: Don&#39;t know how to decode data: 95 0 25 2</code>，正常情况下温湿度均不会返回小数部分。但是返回了，就不知道如何解析数据了。可以修改dht11.c文件的大概152行的部分代码。</p>
<figure class="highlight perl"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><code class="hljs perl"><span class="hljs-keyword">if</span> (hum_int &lt; <span class="hljs-number">4</span>) &#123;  <span class="hljs-regexp">/* DHT22: 100000 = (3*256+232)*100 */</span><br>		dht11-&gt;temperature = (((temp_int &amp; <span class="hljs-number">0x7f</span>) &lt;&lt; <span class="hljs-number">8</span>) + temp_dec) *<br>					((temp_int &amp; <span class="hljs-number">0x80</span>) ? -<span class="hljs-number">100</span> : <span class="hljs-number">100</span>);<br>		dht11-&gt;humidity = ((hum_int &lt;&lt; <span class="hljs-number">8</span>) + hum_dec) * <span class="hljs-number">100</span>;<br>	<span class="hljs-regexp">//</span> &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (temp_dec == <span class="hljs-number">0</span> &amp;&amp; hum_dec == <span class="hljs-number">0</span>) &#123;  <span class="hljs-regexp">/* DHT11 */</span><br>	&#125;<span class="hljs-keyword">else</span>&#123;<br>		dht11-&gt;temperature = temp_int * <span class="hljs-number">1000</span>;<br>		dht11-&gt;humidity = hum_int * <span class="hljs-number">1000</span>;<br>	&#125;<br>	// &#125; <span class="hljs-keyword">else</span> &#123;<br>	<span class="hljs-regexp">//</span> 	dev_err(dht11-&gt;dev,<br>	<span class="hljs-regexp">//</span> 		<span class="hljs-string">&quot;Don&#x27;t know how to decode data: %d %d %d %d\n&quot;</span>,<br>	<span class="hljs-regexp">//</span> 		hum_int, hum_dec, temp_int, temp_dec);<br>	<span class="hljs-regexp">//</span> 	<span class="hljs-keyword">return</span> -EIO;<br>	<span class="hljs-regexp">//</span> &#125;<br></code></pre></td></tr></table></figure>
</li>
<li><p>应用程序</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-type">void</span> <span class="hljs-title function_">getHumidityandTemperature</span><span class="hljs-params">(<span class="hljs-type">lv_timer_t</span> *timer)</span><br>&#123;<br>    <span class="hljs-type">int</span> temperature_file, humidity_file;<br>    temperature_file = open(<span class="hljs-string">&quot;/sys/bus/iio/devices/iio:device1/in_temp_input&quot;</span>, O_RDONLY);<br>    humidity_file = open(<span class="hljs-string">&quot;/sys/bus/iio/devices/iio:device1/in_humidityrelative_input&quot;</span>, O_RDONLY);<br>    <span class="hljs-keyword">if</span> (temperature_file == <span class="hljs-number">-1</span> || humidity_file == <span class="hljs-number">-1</span>)<br>    &#123;<br>        perror(<span class="hljs-string">&quot;Open dhtll files error!\n&quot;</span>);<br>        <span class="hljs-built_in">exit</span>(EXIT_FAILURE);<br>    &#125;<br>    <span class="hljs-comment">// 读取温度值</span><br>    <span class="hljs-type">char</span> temp_buf[<span class="hljs-number">5</span>];<br>    <span class="hljs-type">ssize_t</span> bytesRead = read(temperature_file, temp_buf, <span class="hljs-keyword">sizeof</span>(temp_buf) - <span class="hljs-number">1</span>);<br>    <span class="hljs-keyword">if</span> (bytesRead == <span class="hljs-number">-1</span>)<br>    &#123;<br>        <span class="hljs-comment">// perror(&quot;Error reading temperature file!\n&quot;);</span><br>        close(temperature_file);<br>        <span class="hljs-comment">// exit(EXIT_FAILURE);</span><br>        <span class="hljs-keyword">return</span>;<br>    &#125;<br>    temp_buf[bytesRead] = <span class="hljs-string">&#x27;\0&#x27;</span>;<br>    close(temperature_file);<br>    <span class="hljs-type">int</span> temperature = atoi(temp_buf)/<span class="hljs-number">100</span>;<br>    <span class="hljs-built_in">memset</span>(temp_buf, <span class="hljs-number">0</span>, <span class="hljs-keyword">sizeof</span>(temp_buf));<br>    <span class="hljs-built_in">sprintf</span>(temp_buf, <span class="hljs-string">&quot;%d°C&quot;</span>, temperature);<br><br>    <span class="hljs-comment">// 读取湿度值</span><br>    <span class="hljs-type">char</span> humid_buf[<span class="hljs-number">5</span>];<br>    <span class="hljs-type">ssize_t</span> bytesRead2 = read(humidity_file, humid_buf, <span class="hljs-keyword">sizeof</span>(humid_buf) - <span class="hljs-number">1</span>);<br>    <span class="hljs-keyword">if</span> (bytesRead2 == <span class="hljs-number">-1</span>)<br>    &#123;<br>        <span class="hljs-comment">// perror(&quot;Error reading humidity file!\n&quot;);</span><br>        close(humidity_file);<br>        <span class="hljs-comment">// exit(EXIT_FAILURE);</span><br>        <span class="hljs-keyword">return</span>;<br>    &#125;<br>    humid_buf[bytesRead2] = <span class="hljs-string">&#x27;\0&#x27;</span>;<br>    close(humidity_file);<br>    <span class="hljs-type">int</span> humidity = atoi(humid_buf)/<span class="hljs-number">100</span>;<br>    <span class="hljs-built_in">memset</span>(humid_buf, <span class="hljs-number">0</span>, <span class="hljs-keyword">sizeof</span>(humid_buf));<br>    <span class="hljs-built_in">sprintf</span>(humid_buf, <span class="hljs-string">&quot;%d%cRH&quot;</span>, humidity,<span class="hljs-string">&#x27;%&#x27;</span>);<br><br>    <span class="hljs-comment">// 修改界面</span><br>    lv_label_set_text(ui_templable, temp_buf);<br>    lv_bar_set_value(ui_tempbar, temperature, LV_ANIM_ON);<br><br>    lv_label_set_text(ui_humilable, humid_buf);<br>    lv_bar_set_value(ui_humibar, humidity, LV_ANIM_ON);<br>&#125;<br></code></pre></td></tr></table></figure></li>
</ol>
<h2 id="四、摄像头（SC3336）"><a href="#四、摄像头（SC3336）" class="headerlink" title="四、摄像头（SC3336）"></a>四、摄像头（SC3336）</h2><h2 id="五、LVGL应用"><a href="#五、LVGL应用" class="headerlink" title="五、LVGL应用"></a>五、LVGL应用</h2><h3 id="4-1-移植LVGL"><a href="#4-1-移植LVGL" class="headerlink" title="4.1 移植LVGL"></a>4.1 移植LVGL</h3><ol>
<li><p>github下载仓库代码<a target="_blank" rel="noopener" href="https://github.com/lvgl/lv_port_linux_frame_buffer">lv_port_linux_frame_buffer</a> 、<a target="_blank" rel="noopener" href="https://github.com/lvgl/lvgl/tree/release/v8.3">lvgl-release-v8.3</a>，将lv_port_linux_frame_buffer文件夹中的lvgl替换成新下载的lvgl，</p>
<p>将lv_port_linux_frame_buffer文件夹中的lv_conf.h配置文件替换成lvgl文件夹中的lv_conf_templent文件，并重新命名为lv_conf.h。</p>
<p>拷贝一份lv_port_linux_frame_buffer，并重命名为myui(名字可以随便起).</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs shell">git clone -b release/v8.3 https://github.com/lvgl/lvgl.git<br>git clone https://github.com/lvgl/lv_port_linux_frame_buffer.git<br>cd lv_port_linux_frame_buffer/<br>git submodule update --init --recursive<br></code></pre></td></tr></table></figure>
</li>
<li><p>修改lv_drivers配置文件lv_drv_conf.h</p>
<blockquote>
<ol>
<li><p>默认已使能linux屏幕frambuffer</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-meta">#<span class="hljs-keyword">ifndef</span> USE_FBDEV</span><br><span class="hljs-meta">#  <span class="hljs-keyword">define</span> USE_FBDEV           1</span><br><span class="hljs-meta">#<span class="hljs-keyword">endif</span></span><br><br><span class="hljs-meta">#<span class="hljs-keyword">if</span> USE_FBDEV</span><br><span class="hljs-meta">#  <span class="hljs-keyword">define</span> FBDEV_PATH          <span class="hljs-string">&quot;/dev/fb0&quot;</span></span><br><span class="hljs-meta">#<span class="hljs-keyword">endif</span></span><br></code></pre></td></tr></table></figure>
</li>
<li><p>默认已经使能linux触摸屏幕，只需要修改触摸事件的路径和屏幕尺寸，我的是<code>/dev/input/event0</code> ，尺寸是320*240</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-meta">#<span class="hljs-keyword">ifndef</span> USE_EVDEV</span><br><span class="hljs-meta">#  <span class="hljs-keyword">define</span> USE_EVDEV           1</span><br><span class="hljs-meta">#<span class="hljs-keyword">endif</span></span><br>                                          <br><span class="hljs-meta">#<span class="hljs-keyword">ifndef</span> USE_BSD_EVDEV</span><br><span class="hljs-meta">#  <span class="hljs-keyword">define</span> USE_BSD_EVDEV       0</span><br><span class="hljs-meta">#<span class="hljs-keyword">endif</span></span><br>                                          <br><span class="hljs-meta">#<span class="hljs-keyword">if</span> USE_EVDEV || USE_BSD_EVDEV</span><br><span class="hljs-meta">#  <span class="hljs-keyword">define</span> EVDEV_NAME   <span class="hljs-string">&quot;/dev/input/event0&quot;</span>        <span class="hljs-comment">/*You can use the &quot;evtest&quot; Linux tool to get the list of devices and test them*/</span></span><br><span class="hljs-meta">#  <span class="hljs-keyword">define</span> EVDEV_SWAP_AXES         0               <span class="hljs-comment">/*Swap the x and y axes of the touchscreen*/</span></span><br>                                          <br><span class="hljs-meta">#  <span class="hljs-keyword">define</span> EVDEV_CALIBRATE         0               <span class="hljs-comment">/*Scale and offset the touchscreen coordinates by using maximum and minimum values for each axis*/</span></span><br>                                          <br><span class="hljs-meta">#  <span class="hljs-keyword">if</span> EVDEV_CALIBRATE</span><br><span class="hljs-meta">#    <span class="hljs-keyword">define</span> EVDEV_HOR_MIN         0               <span class="hljs-comment">/*to invert axis swap EVDEV_XXX_MIN by EVDEV_XXX_MAX*/</span></span><br><span class="hljs-meta">#    <span class="hljs-keyword">define</span> EVDEV_HOR_MAX      320               <span class="hljs-comment">/*&quot;evtest&quot; Linux tool can help to get the correct calibraion values&gt;*/</span></span><br><span class="hljs-meta">#    <span class="hljs-keyword">define</span> EVDEV_VER_MIN         0</span><br><span class="hljs-meta">#    <span class="hljs-keyword">define</span> EVDEV_VER_MAX      240</span><br><span class="hljs-meta">#  <span class="hljs-keyword">endif</span>  <span class="hljs-comment">/*EVDEV_CALIBRATE*/</span></span><br><span class="hljs-meta">#<span class="hljs-keyword">endif</span>  <span class="hljs-comment">/*USE_EVDEV*/</span></span><br></code></pre></td></tr></table></figure></li>
</ol>
</blockquote>
</li>
<li><p>修改lvgl配置文件lv_conf.h</p>
<blockquote>
<ol>
<li>使能配置文件</li>
</ol>
  <figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-comment">// 将if 0 改为 if 1</span><br><span class="hljs-meta">#<span class="hljs-keyword">if</span> 1 <span class="hljs-comment">/*Set it to &quot;1&quot; to enable content*/</span></span><br>  <br><span class="hljs-meta">#<span class="hljs-keyword">ifndef</span> LV_CONF_H</span><br><span class="hljs-meta">#<span class="hljs-keyword">define</span> LV_CONF_H</span><br></code></pre></td></tr></table></figure>

<ol start="2">
<li>修改屏幕色深</li>
</ol>
  <figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-comment">/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/</span><br><span class="hljs-meta">#<span class="hljs-keyword">define</span> LV_COLOR_DEPTH 16		<span class="hljs-comment">// 这里我的是16</span></span><br></code></pre></td></tr></table></figure>

<ol start="3">
<li>使能malloc函数</li>
</ol>
  <figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-comment">// 将该宏设为1</span><br><span class="hljs-meta">#<span class="hljs-keyword">define</span> LV_MEM_CUSTOM 1</span><br></code></pre></td></tr></table></figure>

<ol start="4">
<li>使能时钟，修改系统时钟头文件，修改时间函数</li>
</ol>
  <figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-meta">#<span class="hljs-keyword">define</span> LV_TICK_CUSTOM 1</span><br><span class="hljs-meta">#<span class="hljs-keyword">if</span> LV_TICK_CUSTOM</span><br>    <span class="hljs-meta">#<span class="hljs-keyword">define</span> LV_TICK_CUSTOM_INCLUDE <span class="hljs-string">&quot;stdint.h&quot;</span>         <span class="hljs-comment">/*Header for the system time function*/</span></span><br>    <span class="hljs-meta">#<span class="hljs-keyword">define</span> LV_TICK_CUSTOM_SYS_TIME_EXPR (custom_tick_get())    <span class="hljs-comment">/*Expression evaluating to current system time in ms*/</span></span><br>    <span class="hljs-comment">/*If using lvgl as ESP32 component*/</span><br>    <span class="hljs-comment">// #define LV_TICK_CUSTOM_INCLUDE &quot;esp_timer.h&quot;</span><br>    <span class="hljs-comment">// #define LV_TICK_CUSTOM_SYS_TIME_EXPR ((esp_timer_get_time() / 1000LL))</span><br><span class="hljs-meta">#<span class="hljs-keyword">endif</span>   <span class="hljs-comment">/*LV_TICK_CUSTOM*/</span></span><br></code></pre></td></tr></table></figure>

<ol start="5">
<li>使能一个测试demo，只在中文注释的行进行修改</li>
</ol>
  <figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-meta">#<span class="hljs-keyword">define</span> LV_USE_DEMO_WIDGETS 1				<span class="hljs-comment">//这里设为1</span></span><br>  <span class="hljs-meta">#<span class="hljs-keyword">if</span> LV_USE_DEMO_WIDGETS</span><br>  <span class="hljs-meta">#<span class="hljs-keyword">define</span> LV_DEMO_WIDGETS_SLIDESHOW 0</span><br>  <span class="hljs-meta">#<span class="hljs-keyword">endif</span></span><br><br>  <span class="hljs-comment">/*Demonstrate the usage of encoder and keyboard*/</span><br>  <span class="hljs-meta">#<span class="hljs-keyword">define</span> LV_USE_DEMO_KEYPAD_AND_ENCODER 0</span><br><br>  <span class="hljs-comment">/*Benchmark your system*/</span><br>  <span class="hljs-meta">#<span class="hljs-keyword">define</span> LV_USE_DEMO_BENCHMARK 1  			<span class="hljs-comment">//使能该demo，其他的也可以</span></span><br>  <span class="hljs-meta">#<span class="hljs-keyword">if</span> LV_USE_DEMO_BENCHMARK</span><br>  <span class="hljs-comment">/*Use RGB565A8 images with 16 bit color depth instead of ARGB8565*/</span><br>  <span class="hljs-meta">#<span class="hljs-keyword">define</span> LV_DEMO_BENCHMARK_RGB565A8 0</span><br>  <span class="hljs-meta">#<span class="hljs-keyword">endif</span></span><br></code></pre></td></tr></table></figure>

</blockquote>
</li>
<li><p>修改 main.c 文件</p>
<blockquote>
<ol>
<li><p>修改屏幕尺寸，注释鼠标设备</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-comment">// 这里将buf设置为屏幕的尺寸那么大，更大也可以</span><br><span class="hljs-meta">#<span class="hljs-keyword">define</span> DISP_BUF_SIZE (320 * 240)</span><br><br><span class="hljs-comment">// 注册屏幕设备的地方，修改屏幕尺寸</span><br>	<span class="hljs-type">static</span> <span class="hljs-type">lv_disp_drv_t</span> disp_drv;<br> 	lv_disp_drv_init(&amp;disp_drv);<br>    disp_drv.draw_buf   = &amp;disp_buf;<br>    disp_drv.flush_cb   = fbdev_flush;<br>    disp_drv.hor_res    = <span class="hljs-number">320</span>;<br>    disp_drv.ver_res    = <span class="hljs-number">240</span>;<br>    lv_disp_drv_register(&amp;disp_drv);<br><br><span class="hljs-comment">// 注释掉鼠标设备的支持</span><br> <span class="hljs-comment">/*Set a cursor for the mouse*/</span><br> <span class="hljs-comment">// LV_IMG_DECLARE(mouse_cursor_icon)</span><br> <span class="hljs-comment">// lv_obj_t * cursor_obj = lv_img_create(lv_scr_act()); /*Create an image object for the cursor */</span><br> <span class="hljs-comment">// lv_img_set_src(cursor_obj, &amp;mouse_cursor_icon);           /*Set the image source*/</span><br> <span class="hljs-comment">// lv_indev_set_cursor(mouse_indev, cursor_obj);             /*Connect the image  object to the driver*/</span><br></code></pre></td></tr></table></figure>
</li>
<li><p>修改ui代码,默认使用的是lv_demo_widgets()的示例，可将其修改成其他的示例，或者自己用SquareLine Studio 编写的ui界面</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-comment">// 修改ui，可以调用自己用SquareLine Studio生成的ui界面程序</span><br>    <span class="hljs-comment">// lv_demo_widgets();</span><br>    lv_demo_benchmark();<br></code></pre></td></tr></table></figure></li>
</ol>
</blockquote>
</li>
<li><p>编译与运行方法一：Makefile方式</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><code class="hljs makefile">												修改Makefile<br>***********************************************************************************************************************<br>// 添加交叉编译工具链<br>CC = &lt;SDK目录&gt;/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc<br><br><span class="hljs-comment"># 注释掉下面这行</span><br><span class="hljs-comment"># CSRCS 			+=$(LVGL_DIR)/mouse_cursor_icon.c </span><br><br><span class="hljs-comment"># 可以修改生成的执行文件的名字 </span><br>BIN 			= demo<br>												<br>												编译与运行<br>***********************************************************************************************************************<br><br>// 使用最上层的MakeFile编译项目<br>// 编译<br>make<br><br>// 如果感觉编译比较慢，可以查看自己的电脑核心数，如下16是核心数，并行会快很多<br>make -j16<br><br>// 清除<br>make clean<br><br>// 查看编译好的文件,file + 文件名<br>file demo<br>// 生成了ARM架构，32位，小端，可执行文件<br><span class="hljs-section">demo: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-uClibc.so.0, </span><br>with debug_info, not stripped<br><br>// 将可执行文件拷贝到开发板上<br>scp demo root@ip地址:/root<br><br>//执行<br>./demo	  //将占用命令窗口	<br>./demo&amp;   //后台执行<br></code></pre></td></tr></table></figure>
</li>
<li><p>编译与运行方法二：cmake方式</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><code class="hljs shell">											  修改CMakeLists.txt文件<br>***********************************************************************************************************************<br>set(CMAKE_SYSTEM_NAME Linux)	 // 设置目标系统<br>set(CMAKE_SYSTEM_PROCESSOR arm)  // 设置目标架构<br>// 设置C/C++交叉编译工具链<br>set(TOOLCHAINPATH /home/wrt/LuckFox/Max/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf)<br>set(CMAKE_C_COMPILER  $&#123;TOOLCHAINPATH&#125;/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc)<br>set(CMAKE_CXX_COMPILER  $&#123;TOOLCHAINPATH&#125;/bin/arm-rockchip830-linux-uclibcgnueabihf-g++)<br><br>												编译与运行<br>***********************************************************************************************************************<br>mkdir build<br>cd build<br>cmake ..<br>make  或 make -j16<br><span class="hljs-meta prompt_"></span><br><span class="hljs-meta prompt_">#</span><span class="language-bash">此时会在build文件夹生成目标平台的可执行文件</span><br><span class="hljs-meta prompt_">#</span><span class="language-bash">将文件拷贝到开发板上执行即可</span><br></code></pre></td></tr></table></figure>
</li>
<li><p>运行结果</p>
<blockquote>
<img src="/img/lvgl.jpg" srcset="/img/loading.gif" lazyload alt="ac0e2966ec6cf44aa1cf58c3270f968" style="zoom: 33%;" /></blockquote>
</li>
</ol>
<h3 id="4-2-移植文件系统"><a href="#4-2-移植文件系统" class="headerlink" title="4.2 移植文件系统"></a>4.2 移植文件系统</h3><blockquote>
<p>很简单，打开lvgl的配置文件，打开下面的宏，即可</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-comment">/*API for fopen, fread, etc*/</span><br><span class="hljs-meta">#<span class="hljs-keyword">define</span> LV_USE_FS_STDIO 1				<span class="hljs-comment">// 使用c标准api接口，fopen</span></span><br><span class="hljs-meta">#<span class="hljs-keyword">if</span> LV_USE_FS_STDIO</span><br> <span class="hljs-meta">#<span class="hljs-keyword">define</span> LV_FS_STDIO_LETTER <span class="hljs-string">&#x27;S&#x27;</span>     <span class="hljs-comment">/*Set an upper cased letter on which the drive will accessible (e.g. &#x27;A&#x27;)*/</span></span><br> <span class="hljs-meta">#<span class="hljs-keyword">define</span> LV_FS_STDIO_PATH <span class="hljs-string">&quot;&quot;</span>         <span class="hljs-comment">/*Set the working directory. File/directory paths will be appended to it.*/</span></span><br> <span class="hljs-comment">// 设置读取文件的缓存cache大小，根据硬件条件设置大小，设置为1024 Bytes</span><br> <span class="hljs-meta">#<span class="hljs-keyword">define</span> LV_FS_STDIO_CACHE_SIZE 1024    <span class="hljs-comment">/*&gt;0 to cache this number of bytes in lv_fs_read()*/</span></span><br><span class="hljs-meta">#<span class="hljs-keyword">endif</span></span><br></code></pre></td></tr></table></figure>

<p>用下面函数测试：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-type">void</span> <span class="hljs-title function_">FileTest</span><span class="hljs-params">(<span class="hljs-type">void</span>)</span><br>&#123;<br>    <span class="hljs-type">lv_fs_dir_t</span> dir;<br>    <span class="hljs-type">lv_fs_res_t</span> res;<br>    res = lv_fs_dir_open(&amp;dir, <span class="hljs-string">&quot;S:/&quot;</span>);<br>    <span class="hljs-type">char</span> fn[<span class="hljs-number">256</span>];<br>    <span class="hljs-keyword">while</span>(<span class="hljs-number">1</span>) &#123;<br>        res = lv_fs_dir_read(&amp;dir, fn);<br>        <span class="hljs-keyword">if</span>(<span class="hljs-built_in">strlen</span>(fn) == <span class="hljs-number">0</span>) &#123;<br>            <span class="hljs-keyword">break</span>;<br>        &#125;<br>        <span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;%s\n&quot;</span>, fn);<br>    &#125;<br>    lv_fs_dir_close(&amp;dir);<br>&#125;<br><br><span class="hljs-comment">// 执行结果，能够看到打印改文件夹中的内容</span><br># ./luckfoxmax<br>/bin<br>/dev<br>/etc<br>/lib<br>/mnt<br>/oem<br>/opt<br>/run<br>/tmp<br>/sys<br>/var<br>/usr<br>data<br>/proc<br>/sbin<br>/root<br>linuxrc<br>/userdata<br>/rockchip_test<br>lib32<br>lib64<br>/media<br></code></pre></td></tr></table></figure>


</blockquote>
<h3 id="4-3-cmake的使用"><a href="#4-3-cmake的使用" class="headerlink" title="4.3 cmake的使用"></a>4.3 cmake的使用</h3><blockquote>
<p>​	其实，lvgl的工程是一个cmake工程，在项目根目录建立build文件夹，进入build文件夹，执行&#x3D;&#x3D;<code>cmake ..</code>&#x3D;&#x3D;指令，会在该目录下面生成Makefile文件，然后在执行make指令，一样会编译出可执行文件。那么对于后期使用cmake需要修改哪些东西呢？</p>
<ol>
<li><p>修改根路径下的&#x3D;&#x3D;CMakeLists.txt&#x3D;&#x3D;文件，添加交叉编译环境，在project上方，不然可能提示找不到交叉编译工具链</p>
<figure class="highlight cmake"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs cmake"><span class="hljs-keyword">set</span>(TOOLCHAINPATH /home/wrt/LuckFox/Max/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf)<br><span class="hljs-keyword">set</span>(CMAKE_C_COMPILER  <span class="hljs-variable">$&#123;TOOLCHAINPATH&#125;</span>/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc)<br><span class="hljs-keyword">set</span>(CMAKE_CXX_COMPILER  <span class="hljs-variable">$&#123;TOOLCHAINPATH&#125;</span>/bin/arm-rockchip830-linux-uclibcgnueabihf-g++)<br><span class="hljs-keyword">project</span>(luckfoxmax)<br></code></pre></td></tr></table></figure>
</li>
<li><p>设置目标平台的操作系统、处理器架构</p>
<figure class="highlight cmake"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs cmake"><span class="hljs-keyword">cmake_minimum_required</span>(VERSION <span class="hljs-number">3.1</span>)<br><span class="hljs-keyword">set</span>(CMAKE_SYSTEM_NAME Linux)<br><span class="hljs-keyword">set</span>(CMAKE_SYSTEM_PROCESSOR arm)<br></code></pre></td></tr></table></figure>
</li>
<li><p>如果文件A中引用了B头文件，则需要在A的CMakeLists.txt下添加头文件路径</p>
<figure class="highlight cmake"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs cmake">// 如果路径引用到头文件中的最后一个目录，这可以这样引用头文件<br><span class="hljs-comment"># include&lt;B.h&gt;</span><br>// 如果路径没有包含到头文件的最后一层文件夹，则应用头文件需要带上文件夹：如<br><span class="hljs-comment"># include&lt;curl/curl.h&gt;</span><br><span class="hljs-keyword">include_directories</span>(B_HEAD_PATH)<br></code></pre></td></tr></table></figure>
</li>
<li><p>链接库，添加头文件</p>
<figure class="highlight cmake"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><code class="hljs cmake"><span class="hljs-comment"># 比如要使用curl库获取天气信息，并使用cjson库解析json数据，则需要引用如下库</span><br><span class="hljs-keyword">target_link_libraries</span>(<span class="hljs-variable">$&#123;PROJECT_NAME&#125;</span> PRIVATE <span class="hljs-variable">$&#123;LINK_PATH&#125;</span>/libssl.so.<span class="hljs-number">1.1</span>)<br><span class="hljs-keyword">target_link_libraries</span>(<span class="hljs-variable">$&#123;PROJECT_NAME&#125;</span> PRIVATE <span class="hljs-variable">$&#123;LINK_PATH&#125;</span>/libcrypto.so.<span class="hljs-number">1.1</span>)<br><span class="hljs-keyword">target_link_libraries</span>(<span class="hljs-variable">$&#123;PROJECT_NAME&#125;</span> PRIVATE <span class="hljs-variable">$&#123;LINK_PATH&#125;</span>/libcurl.so.<span class="hljs-number">4.8</span>.<span class="hljs-number">0</span>)<br><span class="hljs-keyword">target_link_libraries</span>(<span class="hljs-variable">$&#123;PROJECT_NAME&#125;</span> PRIVATE <span class="hljs-variable">$&#123;LINK_PATH&#125;</span>/libz.so.<span class="hljs-number">1.2</span>.<span class="hljs-number">13</span>)<br><span class="hljs-keyword">target_link_libraries</span>(<span class="hljs-variable">$&#123;PROJECT_NAME&#125;</span> PRIVATE <span class="hljs-variable">$&#123;LINK_PATH&#125;</span>/libcjson.so.<span class="hljs-number">1.7</span>.<span class="hljs-number">15</span>)<br><span class="hljs-comment"># 库链接了，使用的时候需要头文件，要包含头文件的路径</span><br><span class="hljs-keyword">include_directories</span>(<span class="hljs-variable">$&#123;HEADS_PATH&#125;</span>/libcurl-<span class="hljs-number">8.4</span>.<span class="hljs-number">0</span>/<span class="hljs-keyword">include</span>/)<br><span class="hljs-keyword">include_directories</span>(<span class="hljs-variable">$&#123;HEADS_PATH&#125;</span>/cjson-<span class="hljs-number">1.7</span>.<span class="hljs-number">15</span>)<br><span class="hljs-keyword">include_directories</span>(<span class="hljs-variable">$&#123;HEADS_PATH&#125;</span>/libopenssl-<span class="hljs-number">1.1</span>.<span class="hljs-number">1</span>v/<span class="hljs-keyword">include</span>/openssl)<br><span class="hljs-keyword">include_directories</span>(<span class="hljs-variable">$&#123;HEADS_PATH&#125;</span>/libzlib-<span class="hljs-number">1.2</span>.<span class="hljs-number">13</span>)<br><span class="hljs-comment"># 这些库在本机的位置如下</span><br><span class="hljs-keyword">set</span>(HEADS_PATH /home/wrt/LuckFox/Max/luckfox-pico/sysdrv/source/buildroot/buildroot-<span class="hljs-number">2023.02</span>.<span class="hljs-number">6</span>/output/build)<br><span class="hljs-keyword">set</span>(LINK_PATH /home/wrt/LuckFox/Max/luckfox-pico/output/out/rootfs_uclibc_rv1106/usr/lib)<br></code></pre></td></tr></table></figure>
</li>
<li><p>上层CMakeLists.txt添加下层子目录</p>
<figure class="highlight cmake"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs cmake"><span class="hljs-keyword">add_subdirectory</span>(lvgl)<br><span class="hljs-keyword">add_subdirectory</span>(lv_drivers)<br><span class="hljs-keyword">add_subdirectory</span>(components)<br></code></pre></td></tr></table></figure>
</li>
<li><p>依赖另一个文件的头文件</p>
<figure class="highlight cmake"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs cmake"><span class="hljs-keyword">target_include_directories</span>(lvgl PUBLIC <span class="hljs-variable">$&#123;CMAKE_CURRENT_SOURCE_DIR&#125;</span>/../../lvgl/)<br></code></pre></td></tr></table></figure></li>
</ol>
</blockquote>
<h3 id="4-4-Lottie动画移植"><a href="#4-4-Lottie动画移植" class="headerlink" title="4.4 Lottie动画移植"></a>4.4 Lottie动画移植</h3><blockquote>
<ol>
<li><p>下载<a target="_blank" rel="noopener" href="https://github.com/Samsung/rlottie.git">rlottie仓库</a></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">git clone https://github.com/Samsung/rlottie.git<br></code></pre></td></tr></table></figure>
</li>
<li><p>编译rlottie源代码</p>
<figure class="highlight cmake"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs cmake"><span class="hljs-comment"># 首先修改项目的编译工具链，这里直接在CMakeLists.txt中修改了，也可以用其他方式</span><br><span class="hljs-keyword">set</span>(TOOLCHAINPATH /home/wrt/LuckFox/Max/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf)<br><span class="hljs-keyword">set</span>(CMAKE_C_COMPILER  <span class="hljs-variable">$&#123;TOOLCHAINPATH&#125;</span>/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc)<br><span class="hljs-keyword">set</span>(CMAKE_CXX_COMPILER  <span class="hljs-variable">$&#123;TOOLCHAINPATH&#125;</span>/bin/arm-rockchip830-linux-uclibcgnueabihf-g++)<br></code></pre></td></tr></table></figure>
</li>
<li><p>编译，报错</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br></pre></td><td class="code"><pre><code class="hljs c"><span class="hljs-comment">// 编译</span><br>cd rlottie<br>mkdir build<br>cmake ..<br>make -j16<br>    <br><span class="hljs-comment">//大概是这样的错误</span><br>Undefined symbol _pixman_composite_over_n_8888_asm_neon<br><br><span class="hljs-comment">//解决办法,修改文件rlottie/src/vector/vdrawhelper_neon.cpp,整体替换为如下内容</span><br><span class="hljs-comment">//解决办法，在仓库issue中，也可以以打补丁的方式修改，内容很少，修改也很快</span><br>    <br><span class="hljs-meta">#<span class="hljs-keyword">if</span> defined(__ARM_NEON__)</span><br><br><span class="hljs-meta">#<span class="hljs-keyword">include</span> <span class="hljs-string">&quot;vdrawhelper.h&quot;</span></span><br><span class="hljs-meta">#<span class="hljs-keyword">include</span> <span class="hljs-string">&lt;string.h&gt;</span></span><br><span class="hljs-comment">// extern &quot;C&quot; void pixman_composite_src_n_8888_asm_neon(int32_t w, int32_t h,</span><br><span class="hljs-comment">//                                                      uint32_t *dst,</span><br><span class="hljs-comment">//                                                      int32_t   dst_stride,</span><br><span class="hljs-comment">//                                                      uint32_t  src);</span><br><br><span class="hljs-comment">// extern &quot;C&quot; void pixman_composite_over_n_8888_asm_neon(int32_t w, int32_t h,</span><br><span class="hljs-comment">//                                                       uint32_t *dst,</span><br><span class="hljs-comment">//                                                       int32_t   dst_stride,</span><br><span class="hljs-comment">//                                                       uint32_t  src);</span><br><br><span class="hljs-type">void</span> <span class="hljs-title function_">memfill32</span><span class="hljs-params">(<span class="hljs-type">uint32_t</span> *dest, <span class="hljs-type">uint32_t</span> value, <span class="hljs-type">int</span> length)</span><br>&#123;<br>    <span class="hljs-comment">// pixman_composite_src_n_8888_asm_neon(length, 1, dest, length, value);</span><br>    <span class="hljs-built_in">memset</span>(dest, value, length);<br>&#125;<br><br><span class="hljs-type">static</span> <span class="hljs-type">void</span> <span class="hljs-title function_">color_SourceOver</span><span class="hljs-params">(<span class="hljs-type">uint32_t</span> *dest, <span class="hljs-type">int</span> length,</span><br><span class="hljs-params">                                      <span class="hljs-type">uint32_t</span> color,</span><br><span class="hljs-params">                                     <span class="hljs-type">uint32_t</span> alpha)</span><br>&#123;<br>    <span class="hljs-comment">// if (const_alpha != 255) color = BYTE_MUL(color, const_alpha);</span><br>    <span class="hljs-type">int</span> ialpha, i;<br>    <span class="hljs-comment">// pixman_composite_over_n_8888_asm_neon(length, 1, dest, length, color);</span><br>       <span class="hljs-keyword">if</span> (alpha != <span class="hljs-number">255</span>) color = BYTE_MUL(color, alpha);<br>    ialpha = <span class="hljs-number">255</span> - vAlpha(color);<br>    <span class="hljs-keyword">for</span> (i = <span class="hljs-number">0</span>; i &lt; length; ++i) dest[i] = color + BYTE_MUL(dest[i], ialpha);<br>&#125;<br><br><span class="hljs-type">void</span> <span class="hljs-title function_">RenderFuncTable::neon</span><span class="hljs-params">()</span><br>&#123;<br>    updateColor(BlendMode::Src , color_SourceOver);<br>&#125;<br><span class="hljs-meta">#<span class="hljs-keyword">endif</span></span><br><br></code></pre></td></tr></table></figure>
</li>
<li><p>编译通过，将动态链接库复制到开发板上的&#x3D;&#x3D;<strong>&#x2F;usr&#x2F;lib</strong>&#x3D;&#x3D;文件夹中，链接库如下</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs shell"><span class="hljs-meta prompt_"># </span><span class="language-bash">build目录下，建议都复制过去，虽然有两个是连接文件</span><br>librlottie.so<br>librlottie.so.0<br>librlottie.s0.0.2<br></code></pre></td></tr></table></figure>
</li>
<li><p>项目中连接动态库，包含头文件位置</p>
<figure class="highlight cmake"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs cmake"><span class="hljs-comment"># 添加rlottie头文件</span><br><span class="hljs-keyword">include_directories</span>(/home/wrt/LuckFox/rlottie/inc)<br><span class="hljs-comment"># 链接librlottie库</span><br><span class="hljs-keyword">target_link_libraries</span>(<span class="hljs-variable">$&#123;PROJECT_NAME&#125;</span> PRIVATE /home/wrt/LuckFox/rlottie/build/librlottie.so.<span class="hljs-number">0.2</span>)<br></code></pre></td></tr></table></figure>
</li>
<li><p>使用测试</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs c"># 以文件方式载入,注意这里不需要带文件系统标识符，因为使用的是rlottie的文件系统<br><span class="hljs-type">lv_obj_t</span> *lottie2 = lv_rlottie_create_from_file(ui_Panel3, <span class="hljs-number">150</span>, <span class="hljs-number">110</span>, <span class="hljs-string">&quot;/mnt/sdcard/lottie_json/astronut.json&quot;</span>);<br>lv_obj_center(lottie2);<br>                     <br># 从内存中直接载入<br><span class="hljs-keyword">extern</span> <span class="hljs-type">const</span> <span class="hljs-type">uint8_t</span> lottie_data[];<br><span class="hljs-type">lv_obj_t</span>* lottie = lv_rlottie_create_from_raw(parent, width, height, (<span class="hljs-type">const</span> <span class="hljs-type">char</span> *)lottie_data);<br></code></pre></td></tr></table></figure></li>
</ol>
</blockquote>
<h3 id="4-5-使用阿里巴巴矢量库字体"><a href="#4-5-使用阿里巴巴矢量库字体" class="headerlink" title="4.5 使用阿里巴巴矢量库字体"></a>4.5 使用阿里巴巴矢量库字体</h3><blockquote>
<ul>
<li>首先，去<a target="_blank" rel="noopener" href="https://www.iconfont.cn/">阿里巴巴矢量图标库</a>，获取自己想要的资源。加入购物车后，选择下载资源。打开下载下来的html文件，例如：</li>
</ul>
<p><img src="/img/alibaba.png" srcset="/img/loading.gif" lazyload alt="image-20231226221047759"></p>
<ul>
<li><p>在SquareLine Studio 软件中添加字体</p>
<p><img src="/img/font.png" srcset="/img/loading.gif" lazyload alt="image-20231226221340646"></p>
<ul>
<li><p>使用字体，<a target="_blank" rel="noopener" href="https://www.qqxiuzi.cn/bianma/Unicode-UTF.php" title="千千秀字">千千秀字</a>，复制下图中的对应字符到lable中，即可正常显示文字。</p>
<p><img src="/img/format.png" srcset="/img/loading.gif" lazyload alt="image-20231226221458258"></p>
</li>
</ul>
</li>
</ul>
</blockquote>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/LVGL/" class="print-no-link">#LVGL</a>
      
        <a href="/tags/Luckfox-Pico/" class="print-no-link">#Luckfox Pico</a>
      
        <a href="/tags/RV1106/" class="print-no-link">#RV1106</a>
      
    </div>
  
</div>


              

              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2024/04/10/%E6%B3%B0%E5%B1%B1%E6%B4%BE%E7%AC%94%E8%AE%B0/" title="泰山派笔记">
                        <span class="hidden-mobile">泰山派笔记</span>
                        <span class="visible-mobile">Next</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">Search</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">Keyword</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.4/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>





  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.20.1/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">Blog works best with JavaScript enabled</div>
  </noscript>
</body>
</html>
